package servlet.user;


import com.alibaba.fastjson.JSON;
import pojo.Result;
import service.SongsService;
import service.impl.SongsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/user/deleteSongServlet")
public class DeleteSongServlet extends HttpServlet {
    SongsService songsService = new SongsServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String songId = req.getParameter("songId");
        if (songsService.deleteById(Integer.parseInt(songId))){
            Result result = Result.success();
            resp.getWriter().write(JSON.toJSONString(result));
        }else {
            Result result = Result.error("删除失败");
            resp.getWriter().write(JSON.toJSONString(result));
        }

    }
}
